package edu.fzu.crud.controller;

import edu.fzu.crud.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author JohnCarraway
 * @create 2020-12-26 10:11
 */
@Controller
public class LearningController {


    @RequestMapping(value = "/learn/list")
    public String list(Model model){
        List<User> userList = new ArrayList<>();
        User user1 = new User(1, "王小胖");
        User user2 = new User(2,"JohnRambo");
        userList.add(user1);
//        userList.add(user2);
        model.addAttribute("userList", userList);
        return "learn";
    }

    @RequestMapping(value = "/learn/queryAll")
    @ResponseBody
    public String testGetMutiPara(User user){
        System.out.println("id=" + user.getId());
        System.out.println("name=" + user.getName());
        return "learn";
    }
}
